# -*- coding:utf-8 -*-
"""
这里可以做对Django配置的一些自定义处理,比如加载的环境是生产还是测试环境

"""
import os

ENV_DICT = {
    'dev':'dev',
    'pro':'pro',
    'stag':'stag',
}
OS_ENVIRON  = dict(os.environ)
ENV_K = filter(lambda k:OS_ENVIRON.__contains__('DJANGO{env}'.format(env=k).upper()),ENV_DICT)
if not list(ENV_K):
    DJANGO_CONF_MODULE = 'teat_demo.conf.{env}'.format(env=ENV_DICT.get('dev'))
else:
    DJANGO_CONF_MODULE = 'teat_demo.conf.{env}'.format(env='DJANGO{env}'.format(env=ENV_K).upper)

try:
    _module = __import__(DJANGO_CONF_MODULE,globals(),locals(),['*'])
except ImportError as e:
    raise ImportError("Could not import config '%s' (Is it on sys.path?): %s" 
                        % (DJANGO_CONF_MODULE,e))

for _setting in dir(_module):
    if _setting.upper() == _setting:
        locals()[_setting] = getattr(_module,_setting)